package com.itheima.tliasmanagement.mapper;

import com.github.pagehelper.Page;
import com.itheima.tliasmanagement.dto.EmpListDTO;
import com.itheima.tliasmanagement.entity.Emp;
import com.itheima.tliasmanagement.vo.EmpListVo;
import com.itheima.tliasmanagement.vo.EmpVo;
import com.itheima.tliasmanagement.vo.NameValueVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface EmpMapper {

    public List<EmpListVo> selectAll();

    @Select("select count(*) from emp")
    int totalCount();

    List<EmpListVo> selectPage(@Param("start") int start, @Param("pageSize")Integer pageSize);

    Page<EmpListVo> page(EmpListDTO dto);

//    @Options(useGeneratedKeys = true, keyProperty = "id")
//    @Insert("INSERT INTO emp (username, password, name, gender, phone, job, salary, image, entry_date, dept_id, create_time, update_time)" +
//            " VALUES (#{username}, #{password}, #{name}, #{gender}, #{phone}, #{job}, #{salary}, #{image}, #{entryDate}, #{deptId}, #{createTime}, #{updateTime})")
    void insert(Emp emp);

    void deleteByIds(List<Integer> ids);

    @Select("select * from emp where id = #{id}")
    Emp selectById(Integer id);

    EmpVo selectByIdWithExprList(Integer id);

    void update(Emp emp);

    @Select("select * from emp where username = #{username}")
    Emp selectByUsername(String username);

    @Select("select * from emp where phone = #{phone}")
    Emp selectByPhone(String phone);

    List<NameValueVo> empJobData();

    List<NameValueVo> empGenderData();

    @Select("select * from emp")
    List<Emp> all();
}
